package com.ruoyi.web.controller.homepage;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.homepage.domain.UserTags;
import com.ruoyi.homepage.service.IUserTagsService;

/**
 * 用户标签管理
 * 
 * @author ruoyi
 */
@RestController
@RequestMapping("/homepage/usertags")
public class UserTagsController extends BaseController
{
    @Autowired
    private IUserTagsService userTagsService;

    /**
     * 获取用户标签列表
     */
    @PreAuthorize("@ss.hasPermi('homepage:usertags:list')")
    @GetMapping("/list")
    public TableDataInfo list(UserTags userTags)
    {
        startPage();
        List<UserTags> list = userTagsService.selectUserTagsList(userTags);
        return getDataTable(list);
    }

    /**
     * 根据用户标签编号获取详细信息
     */
    @PreAuthorize("@ss.hasPermi('homepage:usertags:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable Long id)
    {
        return success(userTagsService.selectUserTagsById(id));
    }

    /**
     * 新增用户标签
     */
    @PreAuthorize("@ss.hasPermi('homepage:usertags:add')")
    @Log(title = "用户标签管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody UserTags userTags)
    {
        return toAjax(userTagsService.insertUserTags(userTags));
    }

    /**
     * 修改用户标签
     */
    @PreAuthorize("@ss.hasPermi('homepage:usertags:edit')")
    @Log(title = "用户标签管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody UserTags userTags)
    {
        return toAjax(userTagsService.updateUserTags(userTags));
    }

    /**
     * 删除用户标签
     */
    @PreAuthorize("@ss.hasPermi('homepage:usertags:remove')")
    @Log(title = "用户标签管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(userTagsService.deleteUserTagsByIds(ids));
    }
} 